package star.cloud.asme.flowable.task;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import star.cloud.asme.base.dto.Result;
import star.cloud.asme.base.fowable.VO.TaskInstanceQueryCondition;
import star.cloud.asme.base.fowable.baseInterface.FlowableBaseController;
import star.cloud.asme.base.fowable.VO.TaskInstanceVO;
import star.cloud.asme.flowable.task.DTO.CompleteTaskDTO;

import java.util.List;

@RestController
@RequestMapping("/flowable/task")
@RequiredArgsConstructor
public class HqTaskController implements FlowableBaseController<TaskInstanceQueryCondition, TaskInstanceVO> {

    private final HqTaskService hqTaskService;

    @Override
    public Result<TaskInstanceVO> getOneByCondition(String columnName, Object columnValue) {
        return hqTaskService.getOneByCondition(columnName, columnValue);
    }

    @Override
    public Result<TaskInstanceVO> getOneByConditions(TaskInstanceQueryCondition conditions) {
        return hqTaskService.getOneByConditions(conditions);
    }

    @Override
    public Result<List<TaskInstanceVO>> getListByCondition(String columnName, Object columnValue) {
        return hqTaskService.getListByCondition(columnName, columnValue);
    }

    @Override
    public Result<List<TaskInstanceVO>> getListByConditions(TaskInstanceQueryCondition conditions) {
        return hqTaskService.getListByConditions(conditions);
    }

    @Override
    public Result<IPage<TaskInstanceVO>> getListByConditionsWithPage(TaskInstanceQueryCondition conditions) {
        return hqTaskService.getListByConditionsWithPage(conditions);
    }

    @PostMapping("/doTask")
    public Result<?> doTask(CompleteTaskDTO completeTaskDTO) {
        return hqTaskService.doTask(completeTaskDTO);
    }


    @GetMapping("/getCommentListByProcessInstanceId/{processInstanceId}")
    public Result<List<TaskInstanceVO>> getCommentListByProcessInstanceId(@PathVariable String processInstanceId) {
        return hqTaskService.getCommentListByProcessInstanceId(processInstanceId);
    }

}
